package com.stox.services.data.provider.repository.file.iterator;

import com.stox.shared.model.Bar;

public class OffsetAndCountAwareBarIterator extends BarSpanAwareBarIterator {

	private final Integer offset;
	private final Integer count;
	private int counter;
	
	public OffsetAndCountAwareBarIterator(Integer offset, Integer count) {
		this.offset = offset;
		this.count = count;
	}
	
	@Override
	public boolean shouldContinue(Bar bar) {
		if(offset > ++counter){
			return true;
		}
		
		super.shouldContinue(bar);
		
		if(getBars().size() >= count){
			return false;
		}
		
		return true;
	}

	
}
